<%-- 
    Document   : infor
    Created on : 2014/2/27, 上午 11:26:10
    Author     : Gjun
--%>

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%@page import="Filter.DAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    //onclick="javascript: window.open( 'carlist.jsp' , '您的購物車', 'height=300,width=300,toolbar=0,scrollbars=1,status=0')"
    String sql="select * from product";
    DAO db = new DAO();
    ArrayList<HashMap> rslist= db.query(sql, new String[]{});
    String id;
     id= request.getParameter("product_id");
    
    if(id==null)
        id=(String)session.getAttribute("product_id");
    else
         session.setAttribute("product_id", id);
    
    HashMap map =rslist.get(Integer.valueOf(id));
   
    
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <div>
            <div style="float: left;">
                <img src="<%= map.get("img_url")%>" 
                     style="width: 480px;height: 320px;"/>
            </div>
            <div style="float: left;">
                <table border="1" style="width: 300px;height: 320px; padding: 10">
                    <tr>
                        <td>商品名稱</td>
                        <td><%= map.get("product_name")%></td>
                    </tr>
                    <tr>
                        <td>商品價格</td>
                        <td><%= map.get("product_price")%></td>
                    </tr>
                    <tr>
                        <td>商品數量</td>
                        <td><%= map.get("product_stock")%></td>
                    </tr>
                    <tr>
                        <td>商品資訊</td>
                        <td><%= map.get("product_info")%></td>
                    </tr>
                </table>
            </div>
        </div>
                    <form action="carlist" method="post" id="car">
                        <input type="hidden" value="<%=id%>" name="id">
                        <input type="button" value="加入購物車"  onclick="openre()">                    
                    </form>
                     <a href="ProductList.jsp">回列表</a><br>
                    <a href="#" onclick="openre2()" >觀看購物車</a>
                 
                    <script>
                        function openre()
                        {
                           window.document.getElementById("car").submit();
                           window.open('carlist.jsp','您的購物車','height=300,width=300,toolbar=0,scrollbars=1,status=0').reload(true);
                         }
                        function openre2()
                        {
                          window.open( 'carlist.jsp' , '您的購物車', 'height=300,width=300,toolbar=0,scrollbars=1,status=0');
                        }
                     </script>
    </body>
</html>
